import axios from 'axios'
const instance = axios.create({
    baseURL: '/api'
})
instance.interceptors.request.use((config)=>{
    /* 用户信息判断是否有 */
    let token=localStorage.getItem('x-auth-token')
    if(token){
        config.headers['x-auth-token']=token
    }
    return config;
},(error)=>{
    return Promise.reject(error)
})
instance.interceptors.response.use((response)=>{
    console.log('响应拦截器',response)
    if(response.data.code!=0&& response.data.code !=400 && response.data.code !=407){
     /*    alert(response.data.message) */
        return 
    }
    return response
},(error)=>{
    return Promise.reject(error)
})
export default instance